/**
 * @(#)MaiMaiServiceImpl.java 2018年4月3日
 * Copyright(C) 2018年4月3日 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.service.impl;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.jsbd.boss.service.IMaiMaiService;
import org.jsbd.boss.util.MathUtils;
import org.jsbd.boss.util.NameUtils;
import org.jsbd.boss.util.PhoneNumCreateUtils;
import org.jsbd.boss.util.RandomUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;

/**
 * 脉脉Service类
 * @author <a href="mailto:zhouchao@zhexinit.com" >周超</a>
 * @version 1.0.0
 */
@Service("maiMaiService")
public class MaiMaiServiceImpl implements IMaiMaiService {
	public static final Logger LOGGER = LoggerFactory.getLogger(MaiMaiServiceImpl.class);

	@Override
	public List<String> getPhoneAndNickName(String province,String city) {
		int randomNum=RandomUtils.getRandomNum(100)+10;
		
		String phoneArea=PhoneNumCreateUtils.getYidongPhoneArea(province, city);
		if(StringUtils.isBlank(phoneArea)){
			return null;
		}
		
		Map<String,String> repeatPhoneNum=new HashMap<String,String>();
		String[] phoneArr=phoneArea.split(",");
		List<String> dataList=new ArrayList<String>();
		for(int i=0;i<randomNum;i++){
			int index=RandomUtils.getRandomNum(phoneArr.length);
			String phoneNum=phoneArr[index]+MathUtils.getRandomString(4);
			
			String flag=repeatPhoneNum.get(phoneNum);
			if(StringUtils.isNotBlank(flag)){
				continue;
			}
			repeatPhoneNum.put(phoneNum, "1");
			dataList.add( NameUtils.getName()+","+phoneNum);
		}
		return dataList;
	}
}
